<?php
namespace app\question\controller\admin;
use app\common\controller\Admin;
use app\common\annotation\NodeAnnotation;
use app\common\traits\ControllerCurd;
use app\question\model\QuestionSubject;
use think\Request;

/**
 * @NodeAnnotation(
 *     title="题目科目",
 *     parent="question/admin.index",
 *     is_menu=0,
 *     is_view=0,
 *     auth=1,
 * )
 */
class Questsubject extends Admin
{
    use ControllerCurd;
    public $model;
    public function initialize()
    {
        parent::initialize();
        $this->model = new QuestionSubject();
    }

    /**
     * @NodeAnnotation(
     *     title="科目列表",
     *     parent="question/admin.questsubject",
     *     MenuRoot="question/admin.index"
     * )
     */
    public function index()
    {
        $this->assign([
            "subjectList" => $this->model->selectPageDatas()
        ]);

        return $this->fetch();
    }

    /**
     * @NodeAnnotation(
     *     title="添加科目",
     *     parent="question/admin.questsubject",
     *     MenuRoot="question/admin.index",
     *     is_menu = 0
     * )
     */
    public function addsubject(Request $request)
    {
        $this->add(url('question/admin.questsubject/index'));
        return $this->fetch();
    }

    /**
     * @NodeAnnotation(
     *     title="编辑科目",
     *     parent="question/admin.questsubject",
     *     MenuRoot="question/admin.index",
     *     is_menu = 0
     * )
     */
    public function editsubject(Request $request,$id=0)
    {
        $this->assign([
            "subject" =>  $this->model->findData($id),
        ]);
        $this->edit(url('question/admin.questsubject/index'));
        return $this->fetch();
    }

    /**
     * @NodeAnnotation(
     *     title="删除科目",
     *     parent="question/admin.questsubject",
     *     MenuRoot="question/admin.index",
     *     is_menu = 0
     * )
     */
    public function delsubject()
    {
        $this->del();
    }
}